package com.sunwayworld.basemodule.business.report.resource;

import com.alibaba.fastjson.JSONObject;
import com.sunwayworld.basemodule.business.report.bean.LimsReportBean;
import com.sunwayworld.basemodule.business.report.service.LimsReportService;
import com.sunwayworld.framework.log.annotation.Log;
import com.sunwayworld.framework.log.annotation.LogType;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;
import com.sunwayworld.framework.support.auditable.resource.GenericAuditableResource;
import com.sunwayworld.framework.support.base.resource.GenericResource;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RequestMapping("/secure/basemodule/business/reports")
public interface LimsReportResource extends GenericResource<LimsReportService, LimsReportBean, Long>, GenericAuditableResource<LimsReportService, LimsReportBean, Long> {

    @Log(value = "批量生成报告", type = LogType.UPDATE)
    @RequestMapping(value = "/create/reports", method = RequestMethod.GET)
    void createReports(String ids);

    @Log(value = "报告在线预览", type = LogType.SELECT)
    @RequestMapping(value = "/preview-online/reports", method = RequestMethod.GET)
    void previewOnlineReports(String ids, HttpServletRequest request, HttpServletResponse response);

    @Log(value = "报告下载", type = LogType.SELECT)
    @RequestMapping(value = "/download/reports", method = RequestMethod.GET)
    String downloadReports(String ids, HttpServletRequest request, HttpServletResponse response);

    @GetMapping(value = "/open-all-attachs")
    JSONObject openAllAttachs(@RequestParam(value = "ids") String ids);

    @GetMapping(value = "/download-all-attachs")
    JSONObject downloadAllAttachs(@RequestParam(value = "ids") String ids);

    @Log(value = "报告在线预览", type = LogType.SELECT)
    @RequestMapping(value = "/preview-online/reports2", method = RequestMethod.GET)
    void previewOnlineReports2(String ids, HttpServletRequest request, HttpServletResponse response);

    // 搬运自华大
    @Log(value = "特检报告上传",type = LogType.INSERT)
    @RequestMapping(value = {"/upload/tj/report"}, method = RequestMethod.POST)
    JSONObject uploadTjReport(RestJsonWrapperBean wrapper);

    @Log(value = "生成报告", type = LogType.UPDATE)
    @RequestMapping(value = "/create/report", method = RequestMethod.POST)
    void createReport(RestJsonWrapperBean wrapper);

    @Log(value = "生成报告", type = LogType.UPDATE)
    @RequestMapping(value = "/create/auto-report", method = RequestMethod.POST)
    void autoCreateReport(RestJsonWrapperBean wrapper);

}
